	<?php $this->load->view('common/head')?>
	
	<!-- Begin of Sidebar -->
	<?php $this->load->view('common/sidebar')?>
	
	<?php /*********************************/ ?>

<script type="text/javascript" src="<?php echo base_url()?>template/tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
	function valid_save()
	{
		var msg = '';
		if(tinyMCE.get('footer_en').getContent()=='') msg+= 'English Footer Error \n';
		if(tinyMCE.get('footer_ar').getContent()=='') msg+= 'Arabic Footer Error \n';
		if(tinyMCE.get('header_ar').getContent()=='') msg+= 'Arabic Header Error \n';
		if(tinyMCE.get('header_en').getContent()=='') msg+= 'English Header Error \n';

		
		if(msg!=''){
			alert(msg)
		}
		else{
			//alert("Success")
			var forms = $("#form-a,#form-b,#form-c").validate();
			if(forms.form()){
				$.post("<?php echo site_url('mail/save_settings')?>", $("#form-a,#form-b,#form-c").serialize(),
				function(data){
					if(data){
						newdata = $.parseJSON(data);
						if(newdata.error){
							Gtheme = 'error';
							$.each(newdata.msg, function(index) {
								$.jGrowl(newdata.msg[index], { theme: Gtheme,position:'center'  });
							});
						}
						else{
							Gtheme = 'saved';
							$.jGrowl(newdata.msg, { theme: Gtheme,position:'center'  });
						}
					}
					else{
						$.jGrowl("Error!", { theme: 'error' });
					}
				});
			}
		}
	}
	
	
	$().ready(function() {
		
		$('#dialog').dialog({ 
			minWidth: 550,
			position: "top",
			autoOpen: false,
			modal: true, 
			show: "slide", 
			hide: "slide",
			title: "Loading Info..." 
		});
	
		/** Submit Form **/
		$(".form").validate({
				rules:{},
				messages: {},
				submitHandler: function(form) {
				   //submit

				}
			});
		/** End Submit Form **/
		
		
		
		$('#form-c textarea,#form-b textarea').tinymce({
			// Location of TinyMCE script
			script_url : '<?php echo base_url()?>template/tiny_mce/tiny_mce.js',

			// General options
			theme : "advanced",
			plugins : "autolink,lists,pagebreak,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,fullscreen",
			//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Example content CSS (should be your site CSS)
			//content_css : "css/content.css",

			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "<?php echo base_url()?>template/tiny_mce/mhk/image_list.js",
			media_external_list_url : "lists/media_list.js",
			// URL
			relative_urls : false,
			remove_script_host : false,
			document_base_url : "http://grape.dotssol.com/ci/",
			convert_urls : true
		});
	});
	
</script>
<!-- /TinyMCE -->

	<?php /*********************************/ ?>
	<!-- Modal Box Content -->
	<div id="dialog" title="About" style="display: none;">
		<p class='p1'></p>
		<p class='p2'></p>
	</div> 
	<!--! end of #info-dialog -->
			
		<!-- Begin of #main -->
		<div id="main" role="main">
			
			<!-- Begin of titlebar/breadcrumbs -->
			<div id="title-bar">
				<ul id="breadcrumbs">
					<li><a href="<?php echo site_url()?>" title="Home"><span id="bc-home"></span></a></li>
					<li><a href="<?php echo site_url('mail/setting')?>" title="Mail">Mail</a></li>
					<li class="no-hover">Settings</li>
				</ul>
			</div> <!--! end of #title-bar -->
			
			<div class="shadow-bottom shadow-titlebar"></div>
			
			<!-- Begin of #main-content -->
			<div id="main-content">
				<div class="container_12">
				
							
			<!--  -->
			<div class="grid_12">
				<div class="block-border">
				<div class="block-header"><h1>Mail Settings</h1></div>
				<div class="block-content">
						<div class="block-actions">
							<ul class="actions-left">
								<li><button class="submit" onClick="valid_save()">Save</button></li>
							</ul>
						</div>
					</div>
					</div>
			</div>
			
		
			<!--  -->
		<div class="grid_12">
			<div class="block-border">
				<div class="block-header"><h1 id="for_title">General Settings</h1><span></span></div>

					<form id="form-a" class="block-content form" action="" method="post">
						<div class="_75">
							<p class="inline-medium-label">
							<label for="system_email">System Email</label>
							<input id="system_email" name="system_email" class="required email" type="text" value="<?php echo $settings->system_email //set_val($contact,'name')?>" />
							</p>
							
							<p class="inline-medium-label">
							<label for="sender_name" rel="tooltip" title="Sender's name">System Sender Arabic</label>
							<input id="sender_name" name="sender_name" class="required" type="text" value="<?php echo $settings->sender_name//set_val($contact,'name')?>" />
							</p>
							
							<p class="inline-medium-label">
							<label for="sender_name_en" rel="tooltip" title="Sender's name">System Sender English</label>
							<input id="sender_name_en" name="sender_name_en" class="required" type="text" value="<?php echo $settings->sender_name_en//set_val($contact,'name')?>" />
							</p>
							
					</div>
					<div class="clear"></div>
					</form>

			</div>
		</div>
				
			<!--  -->
		<div class="grid_12">
			<div class="block-border">
				<div class="block-header">
					<h1 id="for_title">Emails Header</h1><span></span>
				</div>
				<div class="block-content ">
					<form id="form-b" class="block-content form" method="post">
						<div class="_100">
							<p><label for="header_ar">Header Arabic</label>
							<textarea id="header_ar" name="header_ar" class="tinymce required" rows="2" cols="40"><?php echo $settings->header//set_val($contact,'extra')?></textarea></p>
						</div>
						<div class="_100">
							<p><label for="header_en">Header English</label>
							<textarea id="header_en" name="header_en" class="tinymce required" rows="2" cols="40"><?php echo $settings->header_en?></textarea></p>
						</div>
						<div class="clear"></div>
					</form>
				</div>

			</div>
		</div>
				
			<!--  -->
		<div class="grid_12">
			<div class="block-border">
				<div class="block-header">
					<h1 id="for_title">Email Footer</h1><span></span>
				</div>
				<div class="block-content ">
					<form id="form-c" class="block-content form" method="post">
						<div class="_100">
							<p><label for="footer_ar">Footer Arabic</label>
							<textarea id="footer_ar" name="footer_ar" class="tinymce required" rows="2" cols="40"><?php echo $settings->footer//set_val($contact,'extra')?></textarea></p>
						</div>
						<div class="_100">
							<p><label for="footer_en">Footer English</label>
							<textarea id="footer_en" name="footer_en" class="tinymce required" rows="2" cols="40"><?php echo $settings->footer_en//set_val($contact,'extra')?></textarea></p>
						</div>
						<div class="clear"></div>
					</form>
				</div>

			</div>
		</div>
				
				<div class="clear height-fix"></div>

			</div></div> <!--! end of #main-content -->
	  </div> <!--! end of #main -->	

	
	
	
	<?php /*********************************/ ?>



	<?php /*********************************/ ?>
	<!-- Begin of footer -->
	<?php $this->load->view('common/footer')?>
